﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using ProjetLabo.Class.Utils;

namespace ProjetLabo
{
    /// <summary>
    /// Logique d'interaction pour Window1.xaml
    /// </summary>
    public partial class Step1Window : Window
    {
        public Step1Window()
        {
            InitializeComponent();

            this.projectSelector.Items.Add(CurrentProjectSingleton.PROJECTTYPE_ASP);
            this.projectSelector.Items.Add(CurrentProjectSingleton.PROJECTTYPE_WPF);
            this.projectSelector.Items.Add(CurrentProjectSingleton.PROJECTTYPE_PHONE);
            this.projectSelector.Items.Add(CurrentProjectSingleton.PROJECTTYPE_W8);

            this.SGBDSelector.Items.Add(CurrentProjectSingleton.SGBDTYPE_MYSQL);
            this.SGBDSelector.Items.Add(CurrentProjectSingleton.SGBDTYPE_ORACLE);
            this.SGBDSelector.Items.Add(CurrentProjectSingleton.SGBDTYPE_POSTGR);
            this.SGBDSelector.Items.Add(CurrentProjectSingleton.SGBDTYPE_SQLITE);

            this.projectNotSelected.Visibility = System.Windows.Visibility.Hidden;
            this.SGBDNotSelected.Visibility = System.Windows.Visibility.Hidden;
        }

        private void GoToStep2(object sender, RoutedEventArgs e)
        {

            if (this.projectSelector.SelectedItem == null)
                this.projectNotSelected.Visibility = System.Windows.Visibility.Visible;
            else
                this.projectNotSelected.Visibility = System.Windows.Visibility.Hidden;

            if (this.SGBDSelector.SelectedItem == null)
                this.SGBDNotSelected.Visibility = System.Windows.Visibility.Visible;
            else
                this.SGBDNotSelected.Visibility = System.Windows.Visibility.Hidden;

            if (this.projectSelector.SelectedItem != null && this.SGBDSelector.SelectedItem != null)
            {
                MessageBoxResult MBResult = MessageBox.Show("Vous avez choisi un projet de type "
                                                            + this.projectSelector.SelectedItem.ToString()
                                                            +" et un SGBD de type "
                                                            +this.SGBDSelector.SelectedItem.ToString()
                                                            +". Etes-vous sur de votre choix ?"  
                                                            , "Validation"
                                                            , MessageBoxButton.YesNo);

                if (MBResult == MessageBoxResult.Yes)
                {
                    CurrentProjectSingleton.getInstance.ProjectType = this.projectSelector.SelectedItem.ToString();
                    CurrentProjectSingleton.getInstance.SGBDType1 = this.SGBDSelector.SelectedItem.ToString();

                    Step2Window step2 = new Step2Window();
                    step2.Show();
                    this.Close();
                }

            }
        }
    }
}
